package cn.iocoder.yudao.module.gov.service.resourcecatalog;


import com.alibaba.fastjson.JSONArray;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;


import java.util.*;
import cn.iocoder.yudao.module.gov.controller.admin.resourcecatalog.vo.*;
import cn.iocoder.yudao.module.gov.dal.dataobject.resourcecatalog.ResourceCatalogDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;

import cn.iocoder.yudao.framework.common.util.object.BeanUtils;

import cn.iocoder.yudao.module.gov.dal.mysql.resourcecatalog.ResourceCatalogMapper;



/**
 * 政务资源菜单树 Service 实现类
 *
 * @author 芋道源码
 */
@Service
@Validated
public class ResourceCatalogServiceImpl implements ResourceCatalogService {

    @Resource
    private ResourceCatalogMapper resourceCatalogMapper;

    @Override
    public Long createResourceCatalog(ResourceCatalogSaveReqVO createReqVO) {
        // 插入
        ResourceCatalogDO resourceCatalog = BeanUtils.toBean(createReqVO, ResourceCatalogDO.class);
        resourceCatalogMapper.insert(resourceCatalog);

        // 返回
        return resourceCatalog.getId();
    }

    @Override
    public void updateResourceCatalog(ResourceCatalogSaveReqVO updateReqVO) {
        // 更新
        ResourceCatalogDO updateObj = BeanUtils.toBean(updateReqVO, ResourceCatalogDO.class);
        resourceCatalogMapper.updateById(updateObj);
    }

    @Override
    public void deleteResourceCatalog(Long id) {
        // 删除
        resourceCatalogMapper.deleteById(id);
    }

    @Override
        public void deleteResourceCatalogListByIds(List<Long> ids) {
        // 删除
        resourceCatalogMapper.deleteByIds(ids);
        }

    @Override
    public ResourceCatalogDO getResourceCatalog(Long id) {
        return resourceCatalogMapper.selectById(id);
    }

    @Override
    public PageResult<ResourceCatalogDO> getResourceCatalogPage(ResourceCatalogPageReqVO pageReqVO) {
        return resourceCatalogMapper.selectPage(pageReqVO);
    }

    @Override
    public int deleteAll() {
        return resourceCatalogMapper.deleteAll();
    }

    @Override
    public void saveBatch(List<ResourceCatalogDO> catalogList) {
        resourceCatalogMapper.insertBatch(catalogList);
    }

    @Override
    public List<ResourceCatalogDO> getResourceCatalogList() {
        return resourceCatalogMapper.selectList();
    }

}